<?php
require_once  __DIR__ . '/includes/authenticate.php';
//include_once './db_bb_connect.php';

?>
<h4> Add New Player </h4>
<form class="form-horizontal">
	<div class="form-group">
		<label class="control-label col-sm-4" for="usr">Firstname: </label>
		<div class="col-sm-8">
			<input class="form-control" type="text" name="firstname" placeholder="firstname" />	
			</div>
	</div>
	<div class="form-group">
		<label class="control-label col-sm-4" for="usr">Lastname: </label>
		<div class="col-sm-8">
			<input class="form-control" type="text" name="lastname" placeholder="lastname" />
			</div>
	</div>


	<div class="form-group">
		<label class="control-label col-sm-4" for="usr">Username: </label>
		<div class="col-sm-8">
			<input class="form-control" type="text" name="username" placeholder="username" />	
			</div>
	</div>


	<div class="form-group">
		<label class="control-label col-sm-4" for="usr">Password: </label>
		<div class="col-sm-8">
			<input class="form-control" type="password" name="pwd" placeholder="password" />	

			</div>
	</div>


	<div class="form-group">
		<label class="control-label col-sm-4" for="usr">Confirm Password: </label>
		<div class="col-sm-8">
			<input class="form-control" type="password" name="pwdconfirm" placeholder="confirm password" />	
			</div>
	</div>

	<div class="form-group">
		<div class="col-xs-offset-3 col-sm-offset-4 col-sm-3 col-md-offset-4 col-md-3">
		<button class="btn btn-success" id="addnewplayersubmit" type="submit" name="submit">Add Player </button>
		<button type="reset" class="btn btn-danger ">Reset</button> 
		</div>
	</div>

</form>

<div id="responsemessage"></div>

<script type="text/javascript">

$("#addnewplayersubmit").on("click", function(e) {
    postData = $(this.form).serialize();
    $.ajax({
        type: "POST",
        url: "./includes/handlers/admin_addnewplayer_handler.php",
        data: postData,
        success: function(data) { 
            $("#responsemessage").html(data); 
        },
        error: function (xhr, status, error) {
        	$("#responsemessage").html(xhr.responseText); 
        }
      }); 
    e.preventDefault();
});  

</script>